﻿Imports System.Data.SqlClient
Imports System.Globalization
Imports System.Threading

Public Class Login
    Dim ja As Int16 = 1
    'Dim DA As SqlDataAdapter
    'Dim CB As SqlCommandBuilder
    'Dim TBL As DataTable
    Dim i As Integer = 0
    Dim tbl As New DataTable
    Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click
        'Dim i As Integer = 0
        'Dim msg As String = ""
        'If ja > 5 Then
        '    MessageBox.Show("You enter wrong username or password more than 5 times this program quit now")
        '    Me.Close()
        'End If
        'ja = ja + 1
        'If txtuser.Text = "" Or txtpwd.Text = "" Then
        '    MessageBox.Show("Please input username and password")
        '    Exit Sub
        'ElseIf txtuser.Text <> "" And txtpwd.Text <> "" Then

        '    For i = 0 To tbl.Rows.Count - 1
        '        If LCase(tbl.Rows(i).Item(3)) = LCase(txtuser.Text) And tbl.Rows(i).Item(4) = txtpwd.Text Then
        '            MessageBox.Show("Login Success")
        '            'Me.Visible = False
        '            'frmworktime.emp_id = tbl.Rows(i).Item(0)
        '            'frmworktime.emp_name = tbl.Rows(i).Item(1)
        '            'If tbl.Rows(i).Item(5) = 1 Then
        '            '    MDI_Main.Show()
        '            'Else
        '            '    frmworktime.Show()
        '            'End If
        '            msg = ""
        '            Me.Close()
        '            Exit For

        '        Else
        '            msg = "Login fail"
        '        End If
        '    Next
        '    If msg <> "" Then
        '        MessageBox.Show(msg)
        '    End If

        'Else
        '    MessageBox.Show("Login Fail")
        'End If
        Me.Visible = False
        Main.Visible = True
        Main.Show()
    End Sub

    Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'DA = New SqlClient.SqlDataAdapter("SELECT e.emp_id,e.emp_name ,u.user_id, u.username,u.password FROM employee_tbl e INNER JOIN user_tbl u ON e.EMP_ID=u.EMP_ID INNER JOIN user_type_tbl ut on u.user_type_id=ut.user_type_id ", action.GetConnection)
        'CB = New SqlClient.SqlCommandBuilder(DA)
        'TBL = New DataTable
        'DA.Fill(TBL)
        'tbl = cmd.ExecuteDataTable("SELECT e.emp_id,e.emp_name ,u.user_id, u.username,u.password,ut.user_type_id,ut.user_type FROM employee_tbl e INNER JOIN user_tbl u ON e.EMP_ID=u.EMP_ID INNER JOIN user_type_tbl ut on u.user_type_id=ut.user_type_id ")
        Dim ci As New CultureInfo(My.Settings.Languguage)
        Thread.CurrentThread.CurrentCulture = ci
        Thread.CurrentThread.CurrentUICulture = ci
    End Sub

    Private Sub txtpwd_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtpwd.TextChanged

    End Sub
End Class